//
//  JKROAuthViewController.m
//  YYKitTest
//
//  Created by tronsis_ios on 16/7/13.
//  Copyright © 2016年 tronsis_ios. All rights reserved.
//

#import "JKROAuthViewController.h"

#define APP_KEY @"3690508227"
#define APP_SECRET @"e83c26af6ae0c66e36cedb22a9326bf9"
#define REDIERCT_URL @"http://www.sixstr.me"

@interface JKROAuthViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@end

@implementation JKROAuthViewController

- (instancetype)init {
    self = [super init];
    _webView = [UIWebView new];
    _webView.delegate = self;
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColorHex(f2f2f2);
    _webView.frame = self.view.frame;
    _webView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_webView];
    NSString *urlStr = [NSString stringWithFormat:@"https://api.weibo.com/oauth2/authorize?client_id=%@&response_type=code&redirect_uri=%@", APP_KEY, REDIERCT_URL];
    NSURL *url = [NSURL URLWithString:urlStr];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [_webView loadRequest:request];
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if (![request.URL.absoluteString hasPrefix:REDIERCT_URL]) return YES;
    if ([request.URL.absoluteString hasPrefix:@"code="]) {
    }
    return NO;
}

@end
